<?php
/*******************************************************************************
 *
 *  Name: ViewMyReports
 *
 *  Date: 05/03/2012
 *  
 *  Description: Shows a users created reports to them in a table format
 *  
 *  Author: Travis Rous
 *  
 *  Todo:
 *     NONE
 *
 *  Modification History:  
 * 
 *   Date         Name
 *  ----------   --------------
 *  2012-04-26   TRAVIS ROUS
 *  2012-04-26   TRAVIS ROUS
 *  2012-04-26   TRAVIS ROUS
 *  2012-04-23   TRAVIS ROUS
 *  2012-04-23   TRAVIS ROUS
 *  2012-04-22   TRAVIS ROUS
 * 
 *****************************************************************************/
?>
<h4><?php echo $title; ?></h4>
<?php $message = $this->session->flashdata('message');
      if( $message )
      {
         echo "<p>".$message."</p>";
      }
?>
<table border="none">
<tr>
<td>Choose number of Reports to display: </td>
<td><?php echo "<li>".anchor("CR_form/viewMyReports/5","5")."</li>"; ?></td>
<td><?php echo "<li>".anchor("CR_form/viewMyReports/10","10")."</li>"; ?></td>
<td><?php echo "<li>".anchor("CR_form/viewMyReports/20","20")."</li>"; ?></td>
<td><?php echo "<li>".anchor("CR_form/viewMyReports/50","50")."</li>"; ?></td>
<td><?php echo "<li>".anchor("CR_form/viewMyReports/-1","All")."</li>"; ?></td>
</tr>
</table>
<br>
<br>
<table border="2px"> 
<tr>
<td>ReportID</td>
<td>Report Type</td>
<td>CR ID</td>
<td>Location</td>
<td>Last Edit</td>
<td>View</td>
</tr>

<?php
$flag = $num;
$current_user = $this->session->all_userdata();
$entries = array_reverse ($entries);
foreach ($entries as $entry)
{
   if ($entry["CustomerRepID"] == $current_user["UserID"])
   {
       if($flag != 0)
       {
           echo "<tr>";
           echo '<td>'.$entry["ReportID"].'</td>';
           if ($entry['Sensor'] == 1)
           {
                echo '<td>Sensor</td>';
           }
           else
           {
                echo '<td>Customer</td>';
           }
           echo '<td>'.$entry["CustomerRepID"].'</td>';
           echo '<td>'.$entry["City"].', '.$entry["State"] .'</td>';
           echo '<td>'.$entry["ReportTime"].'</td>';
           echo '<td>'.anchor('CR_form/viewReport/'.$entry["ReportID"].'/',"View/edit") .'</td>';
           echo "<tr>";
           $flag = $flag -1;
       }
    }
}
?>
</table>
